import request from '@/utils/request'

// 获取API列表
export function getApiList(query) {
  return request({
    url: '/interfaces/interfaceInfo/list',
    method: 'get',
    params: query
  })
}

// 获取API详情
export function getApiDetail(id) {
  return request({
    url: '/interfaces/interfaceInfo/' + id,
    method: 'get'
  })
}

// 获取API分类列表
export function getCategoryList() {
  return request({
    url: '/interfaces/interfaceCategory/list',
    method: 'get'
  })
}

// 获取我的API列表
export function getMyApiList(query) {
  return request({
    url: '/front/myapi/list',
    method: 'get',
    params: query
  })
}

// 获取我的API密钥列表
export function getMyApiKeys() {
  return request({
    url: '/front/apikey/listOptimized',
    method: 'get'
  })
}

// 生成新的API密钥
export function generateApiKey(data) {
  return request({
    url: '/front/apikey/generate',
    method: 'post',
    data: data
  })
}

// 更新API密钥状态
export function updateApiKeyStatus(id, status) {
  return request({
    url: '/front/apikey/status',
    method: 'put',
    data: {
      id: id,
      status: status
    }
  })
}

// 删除API密钥
export function deleteApiKey(id) {
  return request({
    url: '/front/apikey/' + id,
    method: 'delete'
  })
}

// 调用API
export function callApi(data) {
  return request({
    url: '/interfaces/call',
    method: 'post',
    data: data
  })
}

// 获取API调用统计
export function getApiStats(query) {
  return request({
    url: '/front/api/stats',
    method: 'get',
    params: query
  })
}

// 获取API调用日志
export function getApiLogs(query) {
  return request({
    url: '/front/api/logs',
    method: 'get',
    params: query
  })
}

// 获取帮助文档列表
export function getHelpList(query) {
  return request({
    url: '/front/help/list',
    method: 'get',
    params: query
  })
}

// 获取帮助文档详情
export function getHelpDetail(id) {
  return request({
    url: '/front/help/' + id,
    method: 'get'
  })
}

// 获取API文档列表
export function getDocList(query) {
  return request({
    url: '/front/doc/list',
    method: 'get',
    params: query
  })
}

// 获取API文档详情
export function getDocDetail(id) {
  return request({
    url: '/front/doc/' + id,
    method: 'get'
  })
} 